<!DOCTYPE HTML><html lang="en">
<HEAD>

<meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2005. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." >

<meta charset="utf-8">
<LINK REL="STYLESHEET" HREF="../book.css" TYPE="text/css">
<TITLE>
Form control
</TITLE>
</HEAD>
<BODY>

<H1>
Form control</H1>
<p><b>Form</b> is a basic control used to host UI Forms. It provides for setting 
a title and scrolling the content similar to a Web browser. What makes forms 
appealing is the fact that the content is an SWT composite that can be used as 
you would use it in other contexts. For example, consider the following code 
snippet:</p>
<blockquote>
	<pre>public class FormView extends ViewPart {
	private FormToolkit toolkit;
	private ScrolledForm form;
	/**
	 * The constructor.
	 */
	public FormView() {
	}
	/**
	 * This is a callback that will allow us to create the viewer and
	 * initialize it.
	 */
	public void createPartControl(Composite parent) {
		toolkit = new FormToolkit(parent.getDisplay());
		form = toolkit.createScrolledForm(parent);
		form.setText(&quot;Hello, Eclipse Forms&quot;);
	}
	/**
	 * Passing the focus request to the form.
	 */
	public void setFocus() {
		form.setFocus();
	}
	/**
	 * Disposes the toolkit
	 */
	public void dispose() {
		toolkit.dispose();
		super.dispose();
	}
}</pre>
</blockquote>
<p>UI Forms manipulate SWT widgets in a number of ways in order to achieve the 
desired effect. For that reason, controls are typically created using the <code>
FormToolkit</code>. Normally an instance of a <code>ScrolledForm</code> is 
created in order to get scrolling. When forms need to be nested, a <code>Form</code> 
instance provides everything except for scrolling of the form content.</p>
<p>Form content is rendered below the title. SWT widgets are created in the form 
using <code>Form.getBody()</code> as a parent.</p>
</BODY>
</HTML>
